#include<iostream>
using namespace std;
char arr[50][50];
int flag[50][50];
int next_1[4][2] = { {0,1},{1,0},{-1,0},{0,-1} };
int sum, n, m;

bool check(int x, int y)
{	
	if (x < n && x >= 0 && y >= 0 && y < m) {
		return 1;
	}
	return 0;
}
void DFS(int x, int y)
{
	for (int i = 0; i < 4; i++) {
		int tx = x + next_1[i][0];
		int ty = y + next_1[i][1];
		if (check(tx, ty)) {
			if (arr[tx][ty] == '.' && flag[tx][ty] == 0) {
				sum++;
				flag[tx][ty] = 1;
				DFS(tx, ty);
			}
		}
	}
}
 int main()
{
	 cin >> m >> n;
	 int x, y;
	 for (int i = 0; i < n; i++) {
		 for (int j = 0; j < m; j++) {
			 cin >> arr[i][j];
			 if (arr[i][j] == '@') {
				 x = i;
				 y = j;
				 flag[x][y] = 1;
			 }
		 }
	 }
	 sum = 1;
	 DFS(x, y);
	 cout << sum << endl;
	return 0;
}